{include file="common/header-top" /}

<link rel="stylesheet" href="/__FRONT__/css/job-index.css?_2019">
<style>
    .help-item-block{

    }
    .help-item-block .van-grid-item__content{
        background-color: #f9fcfa;
        padding: 4px 4px;
    }
    .help-item-block .van-grid-item__content .ven-cell{
        padding: 7px 15px;
    }
</style>


<div id='app' v-cloak>

    <van-nav-bar
            :title="newsTypeInfo.title"
            left-arrow
            @click-left="goBack"
    >
        </van-icon>
    </van-nav-bar>


    <!--新闻列表-->
    <van-list
            v-model="newsListLoading"
            :finished="newsListFinished"
            finished-text="没有更多了"
            @load="getNewsList"
    >

        <van-row v-for="item in newsList" class="job-item" style="    border-bottom: 1px solid #1fb922;">
            <a :href="'/index/News/newsDetail?id=' + item.id" class="job-item-a">
                <van-col span="5">
                    <van-icon :name="getNewsCover(item)" class="job-item-img-icon" size="45px"></van-icon>
                </van-col>

                <van-col span="19">
                    <h4 class="job-item-title">
                        <div class="van-ellipsis">{{item.title}}</div>
                    </h4>
                    <van-cell
                            icon="/__FRONT__/images/icon/eyes.png"
                            :title="getNewsClick(item)"
                    >
                    </van-cell>
                    <van-cell
                            icon="/__FRONT__/images/icon/news-desc.png"
                            :title="item.desc"
                    ></van-cell>

                </van-col>
            </a>
        </van-row>

    </van-list>

    <!--新闻列表-->



    <van-row style="margin-bottom: 85px;">
        <van-cell>
            <van-image src="/__FRONT__/images/icon/apply-process.png"></van-image>
        </van-cell>
    </van-row>

    {include file="common/foot-bar" /}

</div>





<script>
    var vm = new Vue({
        el: '#app',
        data() {
            return {
                active:3,
                userCenterIcon: {
                    normal: '/__FRONT__/images/icon/usercenter-n.png',
                    active: '/__FRONT__/images/icon/usercenter-a.png'
                },
                erShouIcon: {
                    normal: '/__FRONT__/images/icon/ershou-n.png',
                    active: '/__FRONT__/images/icon/ershou-a.png'
                },

                newsTypeId: '{$typeId}',
                newsTypeInfo: {},

                //兼职列表集
                newsList: [],
                newsListPage: 1,
                newsListPageSize: 8,
                newsListLoading: false,
                newsListFinished: false

            }
        },

        created(){


        },

        computed:{
        },

        methods:{

            //返回上一页
            goBack(){
                history.back();
            },

            getNewsCover(item){
                if (item.cover) {
                    return item.cover;
                }
                return '/__FRONT__/images/icon/news-default-cover.png';
            },

            getNewsDetailUrl(item){
                return  '/index/News/newsDetail?id=' + item.id;
            },
            getNewsClick(item){
                if (item.click > 100) {
                    return item.click;
                }
                return Math.round(Math.random()*500);
            },



            getNewsList() {
                var params = {
                    page: this.newsListPage,
                    pageSize: this.newsListPageSize,
                    typeId: this.newsTypeId
                };
                axiosRequest.get('/api/news/newsList',{params:params}).then(function (response) {
                    if (response.code == 200) {
                        if (response.data.newsList) {
                            response.data.newsList.forEach(function(item){
                                vm.$data.newsList.push(item)
                            });
                            vm.$data.newsListLoading = false;
                            vm.$data.newsListPage += 1;

                            vm.$data.newsTypeInfo = response.data.typeInfo;


                            if (response.data.newsList.length < vm.$data.newsListPageSize) {
                                vm.$data.newsListFinished = true;
                                vm.$data.newsListLoading = false;
                            }
                        } else {
                            vant.Toast('没有更多啦！');
                            vm.$data.newsListFinished = true;
                            vm.$data.newsListLoading = false;
                        }
                    } else {
                        vant.Toast('系统开小差啦！');
                    }
                });

            }


        }
    });




</script>

{include file="common/foot-bottom" /}
